package com.honey.mybatis.generator.entity.field;

import com.honey.core.dbmapping.introspect.IntrospectSchema;
import com.honey.core.dbmapping.introspect.IntrospectSchemaColumn;
import com.honey.core.dbmapping.structure.Column;
import com.honey.core.types.FullyQualifiedJavaType;
import com.honey.mybatis.generator.AbstractField;
import com.honey.mybatis.generator.MybatisPlugin;

public class EntityField extends AbstractField {
	
	private Column column = null;
	
	public EntityField( 
			MybatisPlugin belongPlugin,
			IntrospectSchema introspectSchema,
			IntrospectSchemaColumn introspectSchemaColumn) {
		super(null, belongPlugin, introspectSchema, introspectSchemaColumn);
	}
//	
//	public EntityField(Column column, 
//			MybatisPlugin belongPlugin,
//			IntrospectSchema introspectSchema,
//			IntrospectSchemaColumn introspectSchemaColumn) {
//		super(null, belongPlugin, introspectSchema, introspectSchemaColumn);
//		this.column = column;
//	}
//	

	public void setColumn(Column column) {
		this.column = column;
	}

	@Override
	protected String getFieldName() {
		return super.getFieldName(column);
	}

	/* (non-Javadoc)
	 * @see com.honey.mybatis.generator.AbstractField#getType()
	 */
	@Override
	protected FullyQualifiedJavaType getType() {
		return super.getFieldType(introspectSchema.getSchema(), column);
	}

	/* (non-Javadoc)
	 * @see com.honey.mybatis.generator.AbstractField#getJavaDoc()
	 */
	@Override
	protected String[] getJavaDoc() {
		return new String[]{
			this.column.getComment(),
		};
	}
	
	/* (non-Javadoc)
	 * @see com.honey.mybatis.generator.AbstractField#isBaseType()
	 */
	@Override
	protected boolean isBaseType() {
		return  mybatisPlugin.getProjectEnvironmentHolder().isForcePrimitiveType();
	}
}
